﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using System.IO;


namespace Qiang.Controls
{
    /// <summary>
    /// 缩小
    /// </summary>
    [Serializable]
    public class MapFunctionZoomIn : MapFunction
    {
        public MapFunctionZoomIn()
            : base()
        {
            MemoryStream stream = new MemoryStream(Images.cursorZoomIn1);
            Cursor = new System.Windows.Forms.Cursor(stream);
        }



        protected override void OnMouseDown(MapMouseArgs e)
        {



            base.OnMouseDown(e);
        }

        protected override void OnMouseUp(MapMouseArgs e)
        {
            Rectangle r = e.Control.Map.CurrentView;

            int w = r.Width;
            int h = r.Height;

            if (e.Button == System.Windows.Forms.MouseButtons.Left)
            {
                r.Inflate((int)(-r.Width / 4 * e.Control.ScaleFactor), (int)(-r.Height / 4 * e.Control.ScaleFactor));
                r.X += (int)(((e.X / 2) - w / 4) * e.Control.ScaleFactor);
                r.Y += (int)(((e.Y / 2) - h / 4) * e.Control.ScaleFactor);               
                e.Control.Map.ResetExtent(r);
            }
            else
            {
                r.Inflate((int)(r.Width / 2 * e.Control.ScaleFactor), (int)(r.Height / 2 * e.Control.ScaleFactor));
                r.X += (int)((w / 2 - e.X) * e.Control.ScaleFactor);
                r.Y += (int)((h / 2 - e.Y) * e.Control.ScaleFactor);               
                e.Control.Map.ResetExtent(r);
                
            }

            this.MapControl.Invalidate();

            base.OnMouseUp(e);
        }

        protected override void OnMouseWheel(MapMouseArgs e)
        {
            base.OnMouseWheel(e);
        }


    }
}
